/*
 Navicat Premium Dump SQL

 Source Server         : 127.0.0.1
 Source Server Type    : MySQL
 Source Server Version : 50744 (5.7.44)
 Source Host           : 127.0.0.1:3306
 Source Schema         : smart_community

 Target Server Type    : MySQL
 Target Server Version : 50744 (5.7.44)
 File Encoding         : 65001

 Date: 11/08/2025 10:45:16
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sc_unit
-- ----------------------------
DROP TABLE IF EXISTS `sc_unit`;
CREATE TABLE `sc_unit` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '单元ID',
  `unit_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '单元名称',
  `unit_no` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '单元编号',
  `community_id` bigint(20) NOT NULL COMMENT '所属社区ID',
  `building_id` bigint(20) NOT NULL COMMENT '所属楼栋ID',
  `floor_count` int(11) NOT NULL COMMENT '楼层数',
  `room_count` int(11) DEFAULT '0' COMMENT '房间数量',
  `household_count` int(11) DEFAULT '0' COMMENT '户数',
  `has_elevator` tinyint(1) DEFAULT '0' COMMENT '是否有电梯：0-无，1-有',
  `elevator_count` int(11) DEFAULT '0' COMMENT '电梯数量',
  `door_access_type` tinyint(1) DEFAULT '1' COMMENT '门禁类型：1-密码，2-刷卡，3-人脸识别，4-指纹',
  `access_code` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '门禁密码',
  `area` decimal(10,2) DEFAULT NULL COMMENT '单元面积(平方米)',
  `manager_id` bigint(20) DEFAULT NULL COMMENT '单元管理员ID',
  `facilities` json DEFAULT NULL COMMENT '配套设施（JSON格式）',
  `remark` text COLLATE utf8mb4_unicode_ci COMMENT '备注',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态：0-建设中，1-正常使用，2-维修中，3-停用',
  `sort_order` int(11) DEFAULT '0' COMMENT '排序字段',
  `create_by` bigint(20) DEFAULT NULL COMMENT '创建人',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_by` bigint(20) DEFAULT NULL COMMENT '更新人',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除：0-否，1-是',
  `version` int(11) DEFAULT '1' COMMENT '版本号',
  `unit_code` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'å•å…ƒç¼–å·ï¼Œä½œè€…ï¼šWu.Liang',
  `floor_number` int(4) DEFAULT NULL COMMENT 'æ¥¼å±‚å·ï¼Œä½œè€…ï¼šWu.Liang',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_building_unit` (`building_id`,`unit_no`),
  UNIQUE KEY `uk_community_building_unit` (`community_id`,`building_id`,`unit_no`),
  KEY `idx_building_id` (`building_id`),
  KEY `idx_manager_id` (`manager_id`),
  KEY `idx_status` (`status`),
  KEY `idx_community_id` (`community_id`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='单元信息表';

-- ----------------------------
-- Records of sc_unit
-- ----------------------------
BEGIN;
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (1, '1单元', '1', 1, 1, 18, 18, 18, 1, 0, 3, NULL, NULL, NULL, NULL, NULL, 1, 1, 1, '2025-06-21 19:21:53', NULL, '2025-08-01 08:12:20', 0, 1, NULL, NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (2, '2单元', '2', 1, 1, 18, 18, 18, 1, 0, 3, NULL, NULL, NULL, NULL, NULL, 1, 2, 1, '2025-06-21 19:21:53', NULL, '2025-08-01 08:12:20', 0, 1, NULL, NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (3, '3单元', '3', 1, 1, 18, 18, 18, 1, 0, 3, NULL, NULL, NULL, NULL, NULL, 1, 3, 1, '2025-06-21 19:21:53', NULL, '2025-08-01 08:12:20', 0, 1, NULL, NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (4, '4单元', '4', 1, 1, 18, 18, 18, 1, 0, 3, NULL, NULL, NULL, NULL, NULL, 1, 4, 1, '2025-06-21 19:21:53', NULL, '2025-08-01 08:12:20', 0, 1, NULL, NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (5, '1单元', '1', 5, 6, 4, 8, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 9, '2025-07-12 23:27:02', 24, '2025-08-01 08:12:20', 0, 2, '001-1', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (6, '2单元', '2', 5, 6, 4, 8, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 9, '2025-07-12 23:27:02', 24, '2025-08-01 08:12:20', 0, 2, '001-2', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (7, '3单元', '3', 5, 6, 4, 8, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 9, '2025-07-12 23:27:02', 24, '2025-08-01 08:12:20', 0, 2, '001-3', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (8, '1单元', '1', 3, 3, 3, 9, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 9, '2025-07-13 00:13:00', 9, '2025-08-01 08:12:20', 0, 1, '3-1', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (9, '2单元', '2', 3, 3, 3, 9, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 9, '2025-07-13 00:13:00', 9, '2025-08-01 08:12:20', 0, 1, '3-2', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (12, '1单元', '1', 4, 7, 5, 10, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 1, '2025-07-13 19:22:57', 1, '2025-08-01 08:12:20', 0, 1, '6-1', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (13, '2单元', '2', 4, 7, 5, 10, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 1, '2025-07-13 19:22:57', 1, '2025-08-01 08:12:20', 0, 1, '6-2', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (14, '3单元', '3', 4, 7, 5, 10, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 1, '2025-07-13 19:22:57', 1, '2025-08-01 08:12:20', 0, 1, '6-3', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (15, '1单元', '1', 1, 8, 2, 8, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 24, '2025-07-29 11:02:19', 24, '2025-08-01 08:12:20', 0, 1, 'A1-1', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (16, '2单元', '2', 1, 8, 2, 8, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 24, '2025-07-29 11:02:19', 24, '2025-08-01 08:12:20', 0, 1, 'A1-2', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (17, '1单元', '1', 2, 10, 2, 4, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 0, 0, 24, '2025-08-01 12:20:12', 24, '2025-08-01 08:12:20', 0, 1, 'B-1', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (18, '2单元', '2', 2, 10, 2, 4, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 0, 0, 24, '2025-08-01 12:20:12', 24, '2025-08-01 08:12:20', 0, 1, 'B-2', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (19, '3单元', '3', 2, 10, 2, 4, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 0, 0, 24, '2025-08-01 12:20:12', 24, '2025-08-01 08:12:20', 0, 1, 'B-3', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (20, '4单元', '4', 2, 10, 2, 4, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 0, 0, 24, '2025-08-01 12:20:12', 24, '2025-08-01 08:12:20', 0, 1, 'B-4', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (21, '1单元', '1', 9, 12, 3, 6, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 6, '2025-08-08 14:22:17', 6, '2025-08-08 14:22:17', 0, 1, '001-1', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (22, '2单元', '2', 9, 12, 3, 6, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 6, '2025-08-08 14:22:17', 6, '2025-08-08 14:22:17', 0, 1, '001-2', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (23, '3单元', '3', 9, 12, 3, 6, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 6, '2025-08-08 14:22:17', 6, '2025-08-08 14:22:17', 0, 1, '001-3', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (24, '1单元', '1', 10, 13, 2, 4, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 35, '2025-08-08 16:19:47', 35, '2025-08-08 16:19:47', 0, 1, '001-1', NULL);
INSERT INTO `sc_unit` (`id`, `unit_name`, `unit_no`, `community_id`, `building_id`, `floor_count`, `room_count`, `household_count`, `has_elevator`, `elevator_count`, `door_access_type`, `access_code`, `area`, `manager_id`, `facilities`, `remark`, `status`, `sort_order`, `create_by`, `create_time`, `update_by`, `update_time`, `deleted`, `version`, `unit_code`, `floor_number`) VALUES (25, '2单元', '2', 10, 13, 2, 4, 0, 0, 0, 1, NULL, NULL, NULL, NULL, NULL, 1, 0, 35, '2025-08-08 16:19:47', 35, '2025-08-08 16:19:47', 0, 1, '001-2', NULL);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
